/*
 *  Copyright 2012 yura.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.odg.dg.question;

import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

/**
 *
 * @author yura
 */
@Root(name=QuestionsForDocGeneration.QUESTIONS)
public class QuestionsForDocGeneration {

    public static final String QUESTIONS = "Questions";
    public static final String QUESTIONS_XML = QUESTIONS + ".xml";

    @ElementList(inline=true, required=false)
    private ArrayList<QuestionsScreen> questionsScreens = new ArrayList<QuestionsScreen>();

    public ArrayList<QuestionsScreen> getQuestionsScreens() {
        return questionsScreens;
    }

    public void setQuestionsScreens(ArrayList<QuestionsScreen> questionsScreens) {
        this.questionsScreens = questionsScreens;
    }

    public void addQuestionsScreen(QuestionsScreen questionsScreen) {
        questionsScreens.add(questionsScreen);
    }

    public List<Question<?>> getQuestionList() {
        List<Question<?>> list = new ArrayList<Question<?>>();
        for (QuestionsScreen questionsScreen : questionsScreens) {
            for (Question<?> question : questionsScreen.getQuestions()) {
                list.add(question);
            }
        }
        return list;
    }

    public List<String> getGlobalVarList() {
        List<String> list = new ArrayList<String>();
        for(Question<?> question : getQuestionList()) {
            if (question instanceof TextQuestion) {
                list.add(question.getName());
            }
        }
        return list;
    }
}
